******************************************************************************************
* Do-file name:	an_reg_wage_indv_02.do                                                   
* Task:         estimate delata in pure wage effect between model with & without age control         
* Last change:  03.04.2023                                                               
* Notes:                                                                                 
/*
This file contains the code used to generate the results presented in the following tables and figures:
- Table 2:
		-- Age selection: coefficient & std. err of the lincom output below
*/
******************************************************************************************



******************************************************************************************
*** program setup
******************************************************************************************

version 14.2
clear all
macro drop _all
set linesize 90
set more off
* set trace on
discard
set seed 123456789
*set matsize 2000



******************************************************************************************
*** load working dataset
******************************************************************************************

use "data/work_indiv.dta", clear

*** restrict sample
keep if y_nat != .
keep if ao_gem_imp != .

*** drop variables
drop d_emp_* d_wage_* y_to* 

*** create outcome: price effect
sort vsnr_ano year
tsset vsnr_ano year

** bring wage to row of year 1990
foreach x of numlist 1/5 {
local y = 1990 - `x'
gen y_nat_`y' = L`x'.y_nat  if year == 1990
	}

foreach x of numlist 1/5 {
local y = 1990 + `x'
gen y_nat_`y' = F`x'.y_nat  if year == 1990
	}

gen y_nat_1990 = y_nat  if year == 1990


** native wage growth: here as price effect (wage growth of stayers in the same region)
foreach y of numlist 1985/1995 {
gen d_wage_nat_`y'_90 = y_nat_`y' - y_nat_1990  if year == 1990 & nation_gr == 1 & ao_gem_imp_1990 == ao_gem_imp_`y' & ao_gem_imp_1990 != . & ao_gem_imp_`y' != .
	}

*** restrict sample
keep if year == 1990


******************************************************************************************
*** set globals
******************************************************************************************

*** baseline controls
global controls_base  "age"

*** baseline restrictions for wage regerssions
global base_restric_wa "(border_imp_13 == 1 | control_imp == 1) & year == 1990 & nation_gr == 1 & age >= 16 & age <= 65 & weight_fte != ."

* 1) 
global restric_wage_1 "$base_restric_wa"
global sample_wage_1  "All full-time employed workers (natives)"

*** use different czech shocks
foreach year of numlist 1987/1990 1992/1995 {
global czech_shock_`year' "czshare_92_90_predic_13"
	}

global czech_shock_1991   "czshare_91_90_predic_13"



******************************************************************************************
*** estimate price effect
******************************************************************************************

foreach x of numlist 1993 1995 {
*** 1) Price effect: no controls
reg d_wage_nat_`x'_90  ${czech_shock_`x'}                 if $restric_wage_1  [iweight=weight_matching]
est store pe_`x'_90_m1

*** 2) Price effect: age as control (baseline model)
reg d_wage_nat_`x'_90  ${czech_shock_`x'} $controls_base  if $restric_wage_1  [iweight=weight_matching]
est store pe_`x'_90_m2

*** estimate models jointly
suest pe_`x'_90_m1  pe_`x'_90_m2, cluster(ao_kreis_imp)

*** compare models
lincom _b[pe_`x'_90_m1_mean:czshare_92_90_predic_13] - _b[pe_`x'_90_m2_mean:czshare_92_90_predic_13]
	}



******************************************************************************************
*** end
******************************************************************************************

exit


*========================================================================================*
Comments:
- unique identifier: vsnr_ano year
